//
//  HomeYuGaoFromTableViewCell.m
//  Gxj
//
//  Created by 刘伟 on 2017/9/6.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "HomeYuGaoFromTableViewCell.h"
#import "HomeYuGaoParticularsFormView.h"

@interface HomeYuGaoFromTableViewCell ()<SDCycleScrollViewDelegate>
{
    HomeYuGaoParticularsFormView *_particularsView;
    NSInteger inter;
}

@end

@implementation HomeYuGaoFromTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        
    }
    return self;
}

- (void)setModel:(HomeMeetingFromModel *)model
{
    inter = model.list.count;
    [self showScrollView:model];
}

- (void)showScrollView:(HomeMeetingFromModel *)model
{
    //创建滚动视图
    _demoContainerView=[[UIScrollView alloc] initWithFrame:CGRectMake(0, kHeightScale(0), UIScreenWidth, kHeightScale(185))];
    //滚动视图的位置
    _demoContainerView.contentSize = CGSizeMake(kWidthScale(282) * inter + kWidthScale(136),kHeightScale(177));// + kWidthScale(401)
    //是否可以滚动
    _demoContainerView.scrollEnabled = YES;
    //是否可以整夜滚动
    _demoContainerView.pagingEnabled = NO;
    //水平滚动条
    _demoContainerView.showsHorizontalScrollIndicator = NO;
    
    //设置阴影
    _view1=[[UIView alloc] initWithFrame:CGRectMake(kWidthScale(15), kWidthScale(10), kWidthScale(91), kHeightScale(172))];
    _view1.backgroundColor =[UIColor whiteColor];
//    
//    _view1.layer.shadowOffset = CGSizeMake(0, 1);
//    _view1.layer.shadowOpacity = 0.5;
//    _view1.layer.shadowColor = [UIColor blackColor].CGColor;
    _view1.layer.cornerRadius = kWidthScale(12);
    
    _view1.layer.shadowColor = [UIColor blackColor].CGColor;
    _view1.layer.shadowOffset = CGSizeMake(0, 0);
    _view1.layer.shadowOpacity = 0.1;
    //        _shadowView.layer.shadowRadius = 6.0;
    //        _shadowView.layer.cornerRadius = 6.0;
    _view1.clipsToBounds = NO;
    UIImage * image000=[[UIImage alloc]init];
    image000=[UIImage imageNamed:@"圆角矩形-3"];
    _view1.contentMode=UIViewContentModeScaleAspectFit;
    
    
    
    [_demoContainerView addSubview:_view1];
    
    _image=[[UIImageView alloc] initWithFrame:CGRectMake(kWidthScale(13), kHeightScale(30), kWidthScale(64), kHeightScale(64))];
    _image.image=[UIImage imageNamed:@"qiangwei"];
    [_view1 addSubview:_image];
    _qiangText=[[UILabel alloc] init];
    _qiangText.text=@"快来抢吧";
    _qiangText.textAlignment = NSTextAlignmentLeft;
    _qiangText.textColor=[UIColor colorWithRed:(0/255) green:(0/255) blue:(0/255) alpha:1];
    _qiangText.font=[UIFont systemFontOfSize:kWidthScale(16)];
    [_view1 addSubview:_qiangText];
    
    _qiangText.sd_layout
    .topSpaceToView(self.image, kHeightScale(5))
    .leftEqualToView(self.image)
    .widthIs(kWidthScale(70))
    .heightIs(kHeightScale(20));
    
    
    for (int i = 0; i < inter; i++) {
        _particularsView = [[HomeYuGaoParticularsFormView alloc] initWithFrame:CGRectMake(0,0, kWidthScale(278), kHeightScale(172))];
        _particularsView.model = model.list[i];
        _particularsView.backgroundColor = [UIColor colorWithRed:251.0/255.0 green:251.0/255.0 blue:251.0/255.0 alpha:1];
        _particularsView.layer.cornerRadius = kWidthScale(12);
        _particularsView.layer.masksToBounds = YES;
        
        UITapGestureRecognizer *r5 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(doTapChange:)];
        r5.numberOfTapsRequired = 1;
        [_particularsView addGestureRecognizer:r5];
        
        UIView *shadowView = [[UIView alloc]initWithFrame:CGRectMake(kWidthScale(116)+kWidthScale(286)*i, kWidthScale(10), kWidthScale(191), kHeightScale(160))];
        shadowView.layer.shadowColor = [UIColor blackColor].CGColor;
        shadowView.layer.shadowOffset = CGSizeMake(0, 0);
        shadowView.layer.shadowOpacity = 0.2;
        shadowView.clipsToBounds = NO;
        [shadowView addSubview:_particularsView];
        [_demoContainerView addSubview:shadowView];
    }
    [self addSubview:_demoContainerView];
}

//点击
-(void)doTapChange:(UITapGestureRecognizer *)sender{
    if (self.clickHotMeeting) {
        self.clickHotMeeting(@"1");
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
